package com.small.push.config;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 消息推送配置
 * @author dingyou
 * @version 1.0
 * @date 2019-01-10
 */
@ConfigurationProperties(prefix = "push")
@Configuration
public class MsgPushConfig {
    /** 推送模块开关,默认为关闭*/
    private boolean open = false;
    /** 微信消息相关配置*/
    private WeChat wechat;
    /** 邮件信息相关配置*/
    private Email email;
    /** 短信信息相关配置*/
    private SMS sms;

    public boolean isOpen() {
        return open;
    }

    public MsgPushConfig setOpen(boolean open) {
        this.open = open;
        return this;
    }

    public WeChat getWechat() {
        return wechat;
    }

    public MsgPushConfig setWechat(WeChat wechat) {
        this.wechat = wechat;
        return this;
    }

    public Email getEmail() {
        return email;
    }

    public MsgPushConfig setEmail(Email email) {
        this.email = email;
        return this;
    }

    public SMS getSms() {
        return sms;
    }

    public MsgPushConfig setSms(SMS sms) {
        this.sms = sms;
        return this;
    }

    /**
     * 微信模板消息推送
     */
    public static class WeChat {

        /** 发送公众号模板消息url*/
        private String sendTemplateMsgUrl;// https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN

        public String getSendTemplateMsgUrl() {
            return sendTemplateMsgUrl;
        }

        public WeChat setSendTemplateMsgUrl(String sendTemplateMsgUrl) {
            this.sendTemplateMsgUrl = sendTemplateMsgUrl;
            return this;
        }

        @Override
        public String toString() {
            return ToStringBuilder.reflectionToString(this);
        }
    }

    /**
     * 电子邮件推送
     */
    public static class Email{
        @Override
        public String toString() {
            return ToStringBuilder.reflectionToString(this);
        }
    }

    /**
     * 手机短信推送
     */
    public static class SMS{
        @Override
        public String toString() {
            return ToStringBuilder.reflectionToString(this);
        }
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
